import 'package:flutter/material.dart';
import 'package:news_f/home.dart';
import 'package:news_f/mine.dart';

class IndexPage extends StatefulWidget {
  const IndexPage({super.key});

  @override
  State<IndexPage> createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  List<BottomNavigationBarItem> items = [
    BottomNavigationBarItem(
        icon: Icon(Icons.home),
        label: "首页",
        activeIcon: Icon(Icons.home_filled)),
    BottomNavigationBarItem(
        icon: Icon(Icons.people),
        label: "我的",
        activeIcon: Icon(Icons.people_alt))
  ];
  List<Widget> pages = [HomePage(), MinePage()];

  int currentIndex = 0;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(items[currentIndex].label ?? ""),
      ),
      body: pages[currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: items,
        onTap: (index) {
          setState(() {
            currentIndex = index;
          });
        },
        currentIndex: currentIndex,
      ),
    );
  }
}
